Skip to content

Comments

Fix MessageDigest parameter validation, add tests#149

Merged
rlm2002 merged 1 commit intowolfSSL:masterfrom
cconlon:mdArgCheck
Aug 29, 2025
Merged

Fix MessageDigest parameter validation, add tests#149
rlm2002 merged 1 commit intowolfSSL:masterfrom
cconlon:mdArgCheck

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Aug 28, 2025

This PR fixes MessageDigest.update() to throw a RuntimeException for invalid offset/length parameters instead of silently returning.

This includes JUnit tests to protect against regressions.

This fixes OpenJDK SunJCE MessageDigest tests.

@cconlon cconlon self-assigned this Aug 28, 2025
@cconlon cconlon requested a review from Copilot August 28, 2025 21:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes parameter validation in the MessageDigest.update() method to properly throw exceptions for invalid offset/length parameters instead of silently returning, ensuring compliance with OpenJDK SunJCE behavior.

  • Replaces silent return with RuntimeException for invalid parameters in MessageDigest.update()
  • Adds comprehensive JUnit tests for various invalid parameter scenarios
  • Updates method documentation to reflect the new exception behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main/java/com/wolfssl/wolfcrypt/MessageDigest.java Updates parameter validation to throw RuntimeException instead of silently returning
src/test/java/com/wolfssl/wolfcrypt/test/Sha256Test.java Adds test cases for invalid offset/length parameter validation
src/test/java/com/wolfssl/provider/jce/test/WolfCryptMessageDigestSha256Test.java Adds JCE provider test cases for invalid offset/length parameter validation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rlm2002 rlm2002 merged commit 139d5ec into wolfSSL:master Aug 29, 2025
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants